package com.arconsh.designPatterns.singleton;

/**
 * Created by wangyakun on 2017/2/28.
 */
public class Singleton01 {
    private static Singleton01 singleton01 = null;
    private Singleton01(){
        System.out.println("private create instance....");
    }
    public static Singleton01 getInstance(){
        if (singleton01 == null){
            singleton01 = new Singleton01();
            System.out.println("create singleton01....");
        }
        return singleton01;
    }

    public void test(){
        System.out.println("singleton01 test....");
    }
}

class SingletonDemo{
    public static void main(String[] args) {
        Singleton01 singleton01 = Singleton01.getInstance();
        singleton01.test();
    }
}